package com.fofia.iotweb;

import cn.hutool.core.date.DateTime;
import cn.hutool.log.StaticLog;
import com.mybatisflex.core.dialect.DbType;
import com.mybatisflex.core.dialect.DialectFactory;
import com.mybatisflex.core.dialect.KeywordWrap;
import com.mybatisflex.core.dialect.LimitOffsetProcessor;
import com.mybatisflex.core.dialect.impl.CommonsDialectImpl;
import org.noear.solon.Solon;
import org.noear.solon.annotation.SolonMain;
import org.noear.solon.core.event.AppBeanLoadEndEvent;
import org.noear.solon.core.event.AppInitEndEvent;
import org.noear.solon.core.event.AppLoadEndEvent;
import org.noear.solon.core.event.AppPluginLoadEndEvent;
import org.noear.solon.scheduling.annotation.EnableScheduling;

@EnableScheduling
@SolonMain
public class App {
    public static void main(String[] args) {
        Solon.start(App.class, args,app -> {
            //去掉tdengine数据库字段和表名的的外包``符号
            DialectFactory.registerDialect(DbType.MYSQL, new CommonsDialectImpl(KeywordWrap.BACK_QUOTE, LimitOffsetProcessor.MYSQL));
            DialectFactory.registerDialect(DbType.TDENGINE, new CommonsDialectImpl(KeywordWrap.NONE, LimitOffsetProcessor.MYSQL));
               System.setProperty("smarthttp.log.level","OFF");
            //手动读取配置
            //String sqllog=app.cfg().get("solon.boot.sqllog");
            //StaticLog.info("sqllog:{}",sqllog);

            //路由匹配忽略大小写
            app.router().caseSensitive(false);
//            app.onEvent(AppInitEndEvent.class, e->{
//                StaticLog.info("Solon AppInitEndEvent:start ok at :{}",DateTime.now());
//
//            });
//            app.onEvent(AppPluginLoadEndEvent.class, e->{
//                StaticLog.info("Solon AppPluginLoadEndEvent:start ok at :{}",DateTime.now());
//
//            });
//            app.onEvent(AppBeanLoadEndEvent.class, e->{
//                StaticLog.info("Solon AppBeanLoadEndEvent:start ok at :{}",DateTime.now());
//            });
            app.onEvent(AppLoadEndEvent.class, e->{

                StaticLog.info("Solon AppInitEndEvent:start ok at :{}",DateTime.now());

            });


        });
    }
}